Skip to content

land #8885: ECS command path, composed with #8876 - #8888

Merged
proggeramlug merged 2 commits into
mainfrom
land-8885-ecs-command-path
Aug 27, 2026
Merged

land #8885: ECS command path, composed with #8876#8888
proggeramlug merged 2 commits into
mainfrom
land-8885-ecs-command-path

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Lands #8885, rebased onto the main that now contains #8876 and #8872. All six conflicts resolved here rather than asking for a rebase.

The conflicts, and how they were resolved

Two were genuine design overlaps between #8885 and #8876, and both compose — neither side was discarded:

Four resolved toward main, including one where #8885's side was simply empty (it predates #8858's frozen-array throw helpers).

Four follow-on defects surfaced and were fixed: a stale array_has_named_properties import (the merged header.rs only defines _resolved), a dropped AtomicBool/AtomicU8 import, a dropped local QNAN_PREFIX_I64 const, and — the substantive one — five statics that #8885 relocated to a new indexing_support.rs were restored in indexing.rs by hunk-level resolution, producing duplicate #[no_mangle] symbols. Hunk resolution cannot reconstruct a file-level reorganisation when both sides edit the same files.

The soundness test: the assertion was over-broad, not the code unsound

noncanonical_bitwise_method_does_not_gain_raw_number_truthiness failed. It is not pre-existing — it exists on main but not in #8885's base, so a clean rebase would hit it too.

Diagnosis: fcmp one had exactly one source when that test was written — the constructive-proof shortcut (ConstructiveMethodTruthiness::RawNumber), which is genuinely unsound for an arbitrary a & b return. #8885 introduces a second, unrelated source: a general dynamic-truthiness diamond that emits fcmp one only inside its own truthy.num block, after a bit test has proved the value is a plain untagged non-NaN double. There it is exactly correct, and truthy.slow still calls js_is_truthy for strings, BigInt, pointers, handles, int32 boxes and NaN.

I did not invent that distinction. type_analysis/numeric/tests.rs:796 already encodes it, with a doc comment stating it verbatim: "decides a plain (untagged, non-NaN) double inline with fcmp one — but only inside its truthy.num block… An fcmp one anywhere else is the unguarded numeric claim these tests forbid." The failing test's assertion was mirrored onto that helper.

The test's claim is preserved. It still forbids unguarded numeric truthiness, and its first assertion — that @js_is_truthy( must still appear — is untouched and passing. Only the mechanism of checking changed, to account for a second legitimate emitter. match_u32_bitset_test, the structural proof the test guards, is byte-identical to main and still rejects a bare a & b.

Validation (merged tree)

  • all 30 lint-job gates pass
  • perry-codegen 1322, perry-runtime 2749, perry-stdlib 124, perry-hir 348 — all 0 failed
  • moving-GC arm (PERRY_GC_FORCE_EVACUATE=1 PERRY_GC_VERIFY_EVACUATION=1): 16 failed on the batch and 16 on clean main — same-commit A/B, none introduced
  • df checked before and after; no result produced under ENOSPC

Performance claim needs re-measuring

#8885's −40% was measured without #8876, and both campaigns optimise the same ECS hot paths — compare.rs, lower_conditional.rs, array/indexing.rs, arithmetic.rs all took changes from both. Whatever this composed tree performs at, it is not that number. The functional result stands on its own; the figure should be re-taken on the bench mini before it is repeated.

Summary by CodeRabbit

  • Performance

    • Improved ECS command-path performance, with benchmark results showing approximately 36% lower execution time.
    • Added faster handling for comparisons, truthiness checks, arrays, maps, closures, strings, and garbage-collection bookkeeping.
  • Bug Fixes

    • Preserved correct array layout information when arrays are truncated to zero length.
    • Improved handling of stale array-growth references in maps.
    • Corrected type resolution for branded, imported, and generic type aliases.
  • Reliability

    • Strengthened write-barrier behavior and expanded regression coverage for memory management and array operations.

@proggeramlug
proggeramlug merged commit 77b994f into main Aug 27, 2026
17 of 20 checks passed
@proggeramlug
proggeramlug deleted the land-8885-ecs-command-path branch August 27, 2026 18:36
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df49b310-57fb-4651-a541-eda42ce9239d

📥 Commits

Reviewing files that changed from the base of the PR and between fc8c9e9 and 3f2c885.

📒 Files selected for processing (65)
  • changelog.d/8885-ecs-followup-gc-bookkeeping.md
  • crates/perry-codegen/src/codegen/closure.rs
  • crates/perry-codegen/src/codegen/declared_string_add_tests.rs
  • crates/perry-codegen/src/codegen/entry.rs
  • crates/perry-codegen/src/codegen/function.rs
  • crates/perry-codegen/src/codegen/method.rs
  • crates/perry-codegen/src/collectors/proven_this_routing_tests.rs
  • crates/perry-codegen/src/expr/barrier_stem_census_tests.rs
  • crates/perry-codegen/src/expr/compare.rs
  • crates/perry-codegen/src/expr/computed_store_rooting_tests.rs
  • crates/perry-codegen/src/expr/helpers.rs
  • crates/perry-codegen/src/expr/literals_vars.rs
  • crates/perry-codegen/src/expr/mod.rs
  • crates/perry-codegen/src/expr/property_set.rs
  • crates/perry-codegen/src/expr/shadow_inline.rs
  • crates/perry-codegen/src/expr/write_barrier.rs
  • crates/perry-codegen/src/expr/write_pic_barrier_tests.rs
  • crates/perry-codegen/src/function.rs
  • crates/perry-codegen/src/gc_call_effects.rs
  • crates/perry-codegen/src/lower_call/ctor_prologue_store_tests.rs
  • crates/perry-codegen/src/lower_call/typed_shape_bake_tests.rs
  • crates/perry-codegen/src/lower_call/typed_shape_init.rs
  • crates/perry-codegen/src/lower_conditional.rs
  • crates/perry-codegen/src/root_reload.rs
  • crates/perry-codegen/src/runtime_decls/arrays.rs
  • crates/perry-codegen/src/runtime_decls/objects.rs
  • crates/perry-codegen/src/stmt/let_stmt.rs
  • crates/perry-codegen/src/type_analysis/numeric/tests.rs
  • crates/perry-hir/src/lib.rs
  • crates/perry-hir/src/lower_types.rs
  • crates/perry-hir/src/lower_types/branded_intersection_tests.rs
  • crates/perry-hir/src/lower_types/extract.rs
  • crates/perry-hir/src/type_alias_resolve.rs
  • crates/perry-runtime/src/arena/page_meta.rs
  • crates/perry-runtime/src/array/fill_extend.rs
  • crates/perry-runtime/src/array/header.rs
  • crates/perry-runtime/src/array/header_gc_slots.rs
  • crates/perry-runtime/src/array/indexing.rs
  • crates/perry-runtime/src/array/indexing_support.rs
  • crates/perry-runtime/src/array/iter_methods.rs
  • crates/perry-runtime/src/array/mod.rs
  • crates/perry-runtime/src/array/push_pop.rs
  • crates/perry-runtime/src/array/strict_store_tests.rs
  • crates/perry-runtime/src/builtins/arithmetic.rs
  • crates/perry-runtime/src/gc/barrier/mod.rs
  • crates/perry-runtime/src/gc/barrier_store.rs
  • crates/perry-runtime/src/gc/dead_owner.rs
  • crates/perry-runtime/src/gc/dirty_page_cache.rs
  • crates/perry-runtime/src/gc/layout_tables.rs
  • crates/perry-runtime/src/gc/tests/barrier_decoded_parent.rs
  • crates/perry-runtime/src/gc/tests/copying.rs
  • crates/perry-runtime/src/gc/tests/dead_owner_side_tables.rs
  • crates/perry-runtime/src/gc/tests/layout_trace.rs
  • crates/perry-runtime/src/gc/tests/layout_trace/array_layout.rs
  • crates/perry-runtime/src/gc/tests/layout_trace/object_closure_slots.rs
  • crates/perry-runtime/src/gc/tests/layout_trace/per_object_tables.rs
  • crates/perry-runtime/src/gc/tests/oldgen.rs
  • crates/perry-runtime/src/gc/tests/typed_layout_intact_residual.rs
  • crates/perry-runtime/src/json/mod.rs
  • crates/perry-runtime/src/map.rs
  • crates/perry-runtime/src/object/alloc.rs
  • crates/perry-transform/src/closure_local_inline.rs
  • crates/perry-transform/src/lib.rs
  • crates/perry/src/commands/compile/run_pipeline.rs
  • scripts/thread_local_cold_allowlist.json

📝 Walkthrough

Walkthrough

This change adds compiler passes and runtime fast paths for branded type aliases, closure locals, dynamic values, arrays, maps, write barriers, and GC layout bookkeeping. It also adds targeted IR, runtime, and regression tests.

Changes

Compiler and type lowering

Layer / File(s) Summary
Type alias resolution and branded intersections
crates/perry-hir/..., crates/perry/src/commands/compile/run_pipeline.rs
Branded primitive intersections now lower to primitives. Imported and generic aliases resolve across module scopes and re-export chains.
Closure-local cleanup pass
crates/perry-transform/...
Eligible synchronous arrow locals are beta-reduced after inlining. Dead default guards are removed when safe.
Code generation fast paths
crates/perry-codegen/src/expr/..., crates/perry-codegen/src/codegen/...
Dynamic comparisons and truthiness use guarded inline paths. Closure captures, string checks, and arena state use reduced runtime dispatch.
Code generation GC wiring
crates/perry-codegen/src/expr/write_barrier.rs, crates/perry-codegen/src/lower_call/..., crates/perry-codegen/src/runtime_decls/...
Validated-parent barriers and address-sketch layout guards are emitted and classified as non-collecting calls.

Runtime changes

Layer / File(s) Summary
Array and map runtime fast paths
crates/perry-runtime/src/array/..., crates/perry-runtime/src/map.rs
Array length, iteration, strict dense stores, layout rebuilding, and numeric map indexing reuse resolved state and dense storage. Maps retain dense spans and heal forwarded array values.
GC layout and barrier bookkeeping
crates/perry-runtime/src/gc/..., crates/perry-runtime/src/builtins/arithmetic.rs
GC layout records use nursery counts, an address sketch, dead-owner pruning, and separate object thresholds. Barriers support validated parents. typeof and dirty-page caches use hot TLS storage.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Compiler
  participant Codegen
  participant Runtime
  Compiler->>Codegen: lower aliases and optimized expressions
  Codegen->>Runtime: call guarded fast paths
  Runtime-->>Codegen: return resolved values or fallback results
Loading

Suggested reviewers: thehypnoo

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch land-8885-ecs-command-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant